<template>
  <div id="recommend">
    <div class="rec-tit">
      <p class="p-top" @click="goMore">更多推荐</p>
    </div>
    <div class="rec-content">
      <div class="art-card" v-for="(item, i) of recommendData" :key="i">
        <div class="rec-links" @click="gopro(item.gid)">
          <img
            :src="`${baseURL}/jd_card/goods/${item.gpic}`"
            alt=""
          />
          <p class="card-title">
            {{ item.gtitle }}
          </p>
          <p class="card-price">￥{{ item.gprice }}</p>
        </div>
        <div class="add-car" @click.stop></div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      url: "",
      recommendData: []
    };
  },
  methods: {
    goMore() {
      this.$router.push('/sort');
    },
    update(i) {
      console.log(i);
      this.recommendData = i;
    },
    gopro(gid) {
      this.$router.push({
        path: "/products",
        query: {
          gid,
        },
      });
    },
  },
};
</script>
<style lang="scss" scoped>
#recommend {
  background-color: transparent;
  padding-bottom: 0;
  padding: 0.625rem 0 0.3125rem;
  position: relative;
  background-color: #f5f5f5;
  .rec-tit {
    position: relative;
    font-size: 1rem;
    color: #333;
    font-weight: 500;
    padding-left: 0.84375rem;
  }
  .rec-tit::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0.25rem;
    height: 100%;
    background-color: #f23030;
  }
  .rec-content {
    width: 100%;
    padding: 0;
    font-size: 0;
    margin-top: 0.5625rem;
    .art-card {
      display: inline-block;
      width: 49%;
      margin-top: .06rem;
      padding: 0.78125rem 0.71875rem 0.78125rem 0.75rem;
      position: relative;
      background-color: #fff;
      box-sizing: border-box;
      .rec-links {
        outline: 0;
        text-decoration: none;
        img {
          width: 10rem;
          height: 10rem;
        }
        .card-title {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          color: #251d1d;
          line-height: 1rem;
          padding: 0 0.625rem;
          text-align: left;
          font-size: 0.75rem;
          margin-bottom: 0.625rem;
          margin-top: 0.5rem;
          white-space: normal;
        }
        .card-price {
          margin: 0 0 0.3125rem 0;
          padding: 0 0.625rem;
          text-align: left;
          color: #ec3838;
          font-size: 1.125rem;
        }
      }
      .add-car {
        position: absolute;
        margin: 0;
        width: 2.5rem;
        height: 2.5rem;
        right: 0.375rem;
        bottom: 0.375rem;
        background: url("/images/tubiao/addcar.png") no-repeat
          center center;
        background-size: 1.625rem 1.5625rem;
      }
    }
    .art-card:nth-child(2n + 1) {
      margin-right: 0.09375rem;
    }
  }
}
</style>